using UnityEngine;
using System.Collections;

public class LoadView : MonoBehaviour
{
	public LoadManager loadManager;
	public FileLoader fileLoader;
	public GameObject LoadPanel1;
	public GameObject LoadPanel2;
	public GameObject LoadSave;

	private string btnYesName;

	// Use this for initialization
	void Awake ()
	{
		LoadPanel1 = GameObject.Find("LoadPanel1");
		LoadPanel2 = GameObject.Find("LoadPanel2");
		loadManager = GameObject.Find("SaveLoadManager").GetComponent<LoadManager>();
		fileLoader = GameObject.Find("SaveLoadManager").GetComponent<FileLoader>();
		LoadSave = GameObject.Find("LoadSave");

		LoadSave.transform.FindChild("Yes").GetComponent<UIButtonMessage>().target = GameObject.Find("SaveLoadManager");
		LoadSave.transform.FindChild("Yes").GetComponent<UIButtonMessage>().functionName = "loadTargetFile";
		LoadSave.transform.FindChild("No").GetComponent<UIButtonMessage>().target = GameObject.Find("SaveLoadManager");
		LoadSave.transform.FindChild("No").GetComponent<UIButtonMessage>().functionName = "HideLoadSave";

		LoadSave.SetActive(false);
		btnYesName = "Yes";
	}
	
	// Update is called once per frame
	void Update ()
	{

	}

	void loadTargetFile(GameObject item)
	{
		fileLoader.LoadFile(item.name);
		LoadSave.SetActive(false);
	}

	void ShowLoadSave(GameObject item)
	{
		LoadSave.SetActive(true);
		LoadSave.transform.FindChild(btnYesName).name = item.name;
		btnYesName = item.name;
	}

	void HideLoadSave()
	{
		LoadSave.SetActive(false);
	}
}